import React from 'react';
import {
  Form,
  Modal,
} from 'antd';

import DescriptionList from '@/components/DescriptionList';
import * as option from '../../../common/options';

const { Description } = DescriptionList;

// 查看详情
const DescView = Form.create()(props => {
  const { lookDescView, handleLookDesc, selectedRows } = props;
  const couponType = (index) => {
    return index ? <span>{option.couponType[index - 1].value}</span> : '';
  };

  return (
    <Modal
      width={640}

      destroyOnClose
      title="查看详情"
      visible={lookDescView}
      onOk={() => handleLookDesc(false, [])}
      onCancel={() => handleLookDesc(false, [])}>
      {
        selectedRows ?
          <DescriptionList  size="large" style={{ marginBottom: 32 }} col="2">
          <Description term="优惠券编号">{selectedRows.couponNo}</Description>
          <Description term="优惠券名称">{selectedRows.couponName}</Description>
          <Description term="优惠券类型">{couponType(selectedRows.couponType)}</Description>
          {selectedRows.couponType !== 3 ?
            [<Description key={'couponValue'} term="优惠券面值(元）">{selectedRows.couponValue}</Description>,
              <Description key={'minRule'} term="使用下限(元)">{selectedRows.minRule}</Description>] :
            <Description term="优惠券面值(%)">{selectedRows.couponValue}</Description>}
          <Description
            term="适用标的">{selectedRows.newHand === 1 ? '新手标' : ''} {selectedRows.hot === 1 ? 'hot标' : ''} {selectedRows.normal === 1 ? '普通标' : ''}</Description>
          <Description term="状态">{selectedRows.status === 1 ? '启用' : '停用'}</Description>
          <Description term="到期日">{selectedRows.expire}</Description>
          <Description term="发送数量">{selectedRows.sendNum}</Description>
          <Description term="使用数量">{selectedRows.useNum}</Description>
          <Description term="创建人">{selectedRows.createName}</Description>
          <Description term="创建时间">{selectedRows.createTime}</Description>
          <Description term="备注">{selectedRows.remark}</Description>

        </DescriptionList> : ''
      }
    </Modal>
  );
});

export default DescView;
